package org.btik.lightweb.client;

import org.btik.light.server.platform.common.api.bean.dev.access.DevAccountDto;
import org.btik.light.server.platform.common.api.bean.dev.access.DevAccountVo;
import org.btik.light.server.platform.common.api.bean.sensitive.annotation.SensitiveBody;
import org.btik.light.server.platform.common.api.service.DevAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.Map;

/**
 * @author lustre
 * @since 2023/6/3 14:21
 */

@RestController
@RequestMapping("/devAccount")
public class DevAccountController {
    @Autowired
    private DevAccountService devAccountService;
    @GetMapping("/list")
    public Collection<DevAccountVo> list() {
        return devAccountService.list();
    }

    @GetMapping("/getMdAlgorithms")
    public Map<String,String> getMdAlgorithms() {
        return devAccountService.getMdAlgorithms();
    }

    @PostMapping("/saveAccount")
    public boolean saveAccount(@SensitiveBody DevAccountDto devAccountDto){
        return devAccountService.saveAccount(devAccountDto);
    }

    @GetMapping("/delete")
    public boolean delete(String username) {
        return devAccountService.delete(username);
    }
    @GetMapping("/changeStatus")
    public boolean changeStatus(String username,Boolean status){
        return devAccountService.changeStatus(username,status);
    }

    @GetMapping("/getUserByName")
    public DevAccountVo getUserByName(String username) {
        return devAccountService.getUserByName(username);
    }
}
